#include <iostream>
#include <math.h>
using namespace std;
const int inf=0x7fffffff;


int lg2(int x){
	return (int)log2(x);
}

int p2(int x){
	return (int)pow(2,x);
}


struct node{
	int index,num;
};



node max(node a,node b){
	if(a.num > b.num)
		return a;
	else
		return b;
}


node min(node a,node b){
	if(a.num < b.num)
		return a;
	else
		return b;
}


int main(){
	int n,m,q;
	cin>>n>>m>>q;
	node st1[n][lg2(n)+1],st2[m][lg2(m)+1];
	int a[n],b[m];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	
	for(int i=0;i<n;i++)
		st1[i][0].num = inf;
	for(int i=0;i<m;i++)
		st2[i][0].num = inf+1;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(st1[i][0].num > a[i]*b[j])
				st1[i][0] = (node){i,a[i]*b[j]};
			if(st2[j][0].num < a[i]*b[j])
				st2[j][0] = (node){j,a[i]*b[j]};
		}
	}
	
	
	for(int i=1;i<=lg2(n);i++){
		for(int j=0;j+p2(i)-1<n;j++){
			st1[j][i] = max(st1[j][i-1],st1[j+p2(i-1)][i-1]);
		}
	}
	
	for(int i=1;i<=lg2(m);i++){
		for(int j=0;j+p2(i)-1<m;j++){
			st2[j][i] = min(st2[j][i-1],st2[j+p2(i-1)][i-1]);
		}
	}
	
	cout<<endl;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<=lg2(n);j++){
			cout<<st1[i][j].num<<" ";
		}
		cout<<endl;
	}
	
	cout<<endl;
	
	for(int i=0;i<m;i++){
		for(int j=0;j<=lg2(m);j++){
			cout<<st2[i][j].num<<" ";
		}
		cout<<endl;
	}
	
	cout<<endl;	
	
	
	for(int k=0;k<q;k++){
		int l1,r1,l2,r2;
		cin>>l1>>r1>>l2>>r2;
		l1--,l2--,r1--,r2--;
		node ans1,ans2;
		ans1 = max(st1[l1][lg2(r1-l1+1)],st1[r1-p2(lg2(r1-l1+1))+1][lg2(r1-l1+1)]);
		ans2 = min(st2[l2][lg2(r2-l2+1)],st1[r2-p2(lg2(r2-l2+1))+1][lg2(r2-l2+1)]);
		cout<<a[ans1.index]*b[ans2.index]<<endl;
	}
	return 0;
}
